package com.xy.biz.xd.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.xd.domain.query.DocumentFlowQuery;
import com.xy.biz.xd.domain.req.GenerateDocumentRequest;
import com.xy.biz.xd.domain.req.ListLedgerDataRequest;
import com.xy.biz.xd.domain.req.documentRelease.ListDocumentReleaseRequest;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.xd.domain.bo.DocumentReleaseBO;
import com.xy.biz.xd.domain.po.DocumentReleasePO;
import com.xy.biz.xd.domain.query.DocumentReleaseQuery;
import com.xy.biz.xd.domain.resp.GetDocumentReleaseResponse;
import com.xy.biz.xd.domain.req.SaveDocumentReleaseRequest;

/**
 *
 *
 * @author wcs
 * @date 2021-3-4
 */
public class DocumentReleaseConverter {

    public static DocumentReleasePO toPO(DocumentReleaseBO source) {
        return BeanUtilsEx.copyProperties(source, () -> new DocumentReleasePO(), true);
    }

    public static DocumentReleasePO toPO(DocumentReleaseQuery source) {
        return BeanUtilsEx.copyProperties(source, () -> new DocumentReleasePO(), true);
    }

    public static List<DocumentReleasePO> toPO(Collection<DocumentReleaseBO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentReleasePO(), true);
    }

    public static DocumentReleaseBO fromPO(DocumentReleasePO source) {
        return BeanUtilsEx.copyProperties(source, () -> new DocumentReleaseBO());
    }

    public static List<DocumentReleaseBO> fromPO(Collection<DocumentReleasePO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentReleaseBO());
    }

    public static DocumentReleaseBO toBO(SaveDocumentReleaseRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new DocumentReleaseBO(), true);
    }

    public static List<DocumentReleaseBO> toBO(Collection<SaveDocumentReleaseRequest> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentReleaseBO(), true);
    }

    public static GetDocumentReleaseResponse toResponse(DocumentReleaseBO source) {
        return BeanUtilsEx.copyProperties(source, () -> new GetDocumentReleaseResponse());
    }

    public static ListDocumentReleaseRequest toRequest(ListLedgerDataRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new ListDocumentReleaseRequest());
    }

    public static List<GetDocumentReleaseResponse> toResponse(Collection<DocumentReleaseBO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetDocumentReleaseResponse());
    }

    public static DocumentReleaseQuery toQuery(ListDocumentReleaseRequest source) {
        if (null == source) {
            return null;
        }
        DocumentReleaseQuery target = new DocumentReleaseQuery(source.getPageIndex(), source.getPageSize());
        BeanUtilsEx.copyProperties(source, target);
        return target;
    }

    public static DocumentReleaseQuery toQuery(ListLedgerDataRequest source) {
        if (null == source) {
            return null;
        }
        DocumentReleaseQuery target = new DocumentReleaseQuery(source.getPageIndex(), source.getPageSize());
        BeanUtilsEx.copyProperties(source, target);
        return target;
    }

    public static DocumentReleaseQuery toQuery(GenerateDocumentRequest source) {
        if (null == source) {
            return null;
        }
        DocumentReleaseQuery target = new DocumentReleaseQuery(source.getPageIndex(), source.getPageSize());
        return target;
    }

}
